More work on tests.  Bug fixes.