- added some unit tests and refactored