internal/v4: refactor tests

We create a table with an entry for each kind of metadata so
that it's easy to add new entries and new tests that
test the metadata in arbitrary configurations without
writing reams of duplicated test code.

We also fix router so that it works correctly with
typed nil data, which avoids an if statement in
every metadata handler.
I wonder if, in order to make the cases more explicit, we can just put the returned value here without fetching it dynamically with entityFieldGetter/entityGetter. Otherwise it seems those functions are non-trivial enough to deserve their own tests. What do you think?