Fix unit test to be less error-prone.