some refactoring, made tests more verbose