Merge in unit tests and code enhancements