refactor; improved tests; also closes #10