Add unit tests.
Fix up unit test