Refactored code. Created tests for new Class.