more tests, more refactor