added unit tests & fixed errors