[TASK] Refactoring and test coverage