Added heartbeat internal method with tests