Fix a race condition in a test.