Adjust test wait condition to make it resilient to different timing.