Little more refactoring, comments and UnitTest