adds encoder tests, ensures saveCtx is closed