Added first batch of unit tests and corrected an error