some refactoring, better isolation of tests