Refactoring of randomly failing tests