Added method to make testeable new code and added tests