Added unit some enities unit tests. Refactored some code in order to make bulidable and fix some implementation errors