refactoring code
factory tests created.