Fix flaky heartbeat test by ensuring time deadline is hit