pubsub event encoding for json based streams

also includes
 - added/fixed some tests