[TASK] Cleanups and refactoring aiming for better test coverage