Synchronizing a test with custom-expected conditions