moving sleep to end of loop, so we quit immediately if the test succeeds