Fixed possible race condition in unit test.