Extracted helper functions from functional_test_wait().