Simplify and fix tests with factories