Fix test to avoid async race condition.