Added UnitTest and some minor changes