During the 1800's people developed the fear of being buried alive. Opportunistic merchants offered to sell special coffins and tombstones. A string was tied to the dead person's finger or hand. The other end was tied to a bell that sat on top of the grave marker. If the not-so-dead person woke up they could ring the bell to be dug up.
This practice stopped when too many bells would go off in cemeteries. as rigamortis would set in or muscles relaxed after death the hand would move and the bell would ring. Graveyard attendants would run with their shovels to dig up the unfortunate individual only to find they they were very dead. This is where the term a "dead ringer" comes from.