Add some more tests for templates and nested classes - and fix others.