Adding unit tests and fixing up the test failures.