Add a test for definition includes, fix bugs revealed by test.