Various minor fixes that were discovered during unittest development.