Improve protocol definition

While it used less space, the old protocol definition was really
not nice and pythonic. Now it's far nicer and features more tests.