Added unit tests and refactored methods to enable better testing. Fixed
build errors from cocoapods integration.