fix race condition in test cases