test fixes & small refactoring