- some refactoring
- added some tests