Added a test suite, refactored