Refactored some code into extensions.
Added integration tests to the new extensions.