refactor a mock server in client_test
more test factoring
client tests no longer rely on an external server!
(failing) test for handling really long lines
refactor the json framing code to be generic
Rewrite the protocol to be pure-JSON.

Among other things, this lets use json.Encoder and Decoder directly, for
less copying and no arbitrary line-length limits.