fix race conditions in unit tests