further refactoring. adds new tests
pass first paper test