Move tests infra to look like all other middleware, and some small cleanups.
Split up the handler_test in four files that all tests their specific bits. Removed the CNAME sort as there was only 1 answer with a CNAME and that was a single one. See #942, this fixes (a bit) the tests in middleware.