Correctly handle `at-subdoc` and add tests.