Refactored Factory class and added code coverage