Fix intermittent unit test failures