Refactored some methods into pogos to improve testability. Added tests for these methods