more unittest, start of refactoring