Fix issue #309 and add tests.
Add a failing test case for a type name issue revealed by issue #309.
Fix issue 305 and add a test.