more tests + refactorings