refactor and add unit tests
make tests pass
add in new class
more refactoring