some refactoring and test suite started