more unittests, small refactorings