Refactoring and test coverage boost