Fix unit test failing randomly