Refactored code and removed unnecessary tests