prevent race condition, fix test