Removed unreachable exception.
Added a bunch of integration tests that cover all the relevant code.
Cleaned up tests somewhat