refactorama
partially fixed #7, low-level tests in place