added new unit tests and fixed some bugs
fixed small exception bugs