Refactored the test suite.

Makes the tests more manageable. Also corrects some minor issues that should have been detected by the previous test suite.