Add TestProcessHeartbeat, fix a related bug