Refactored code with improved test coverage.
Merge