removed unused code, wrote tests for refactored code