removed phactory, added unit tests and refactored few codes