Fix test race condition