Rework the protocol decoder for queries.

This is much work in progress, but we are aiming for recreating the protocol encoder/decoder
in a way that is testable, over not being testable at all. This means encoding and decoding has
to be inverses of each other, which they were not. This commit fixes the problem by forcing
encoding of queries to have a logical inverse as a non-query.

Responses still need to be handled appropriately.
Handle encoding/decoding of errors.
Implement response coding/decoding.

It turns out it breaks, because we don't really understand what we are trying to do in the first place.