Additional unit tests and code fixes.
Ready for other developers to use now.