adding some factories and refactoring tests