improve unit test to be less sensitive to a time delay