more tests and refactors