More refactoring, added a test suite integrating some previous tests.