small refactoring and split some tests apart