Added new unit tests and some minor changes