Minor refactoring for testability improvements
Adding more detailed tests