Improved the test suite. Added an integration test.