Fix intermittent test failures