Unit test updates and fixes, and some minor cleanup.