Added unit tests; corrections