Improve testability and test coverage