fix race condition in unit test