Added unit tests (fully tested) with some minor refactorings