Added unit tests and corrected some errrors