fixing test and some refactoring