Refactor tests factories in a separate file