Fix/codec encode context

this fixes #1523 
yeah, and it basically so I can mock the exchange in specs