Adds heartbeats test and enhances agent and endpoint shutdowns