fix: Encode body and update resp.body

The patch sets the encoded body to resp.body so that other functions /
calls using it can operate on the updated value, which is the one that
will be sent back to the client.

fixes #158
fix: keep body and make encoding process explicit
Added some docstrings and tests
fix: Added missing tests and rebased fixes #158
Merge pull request #159 from FlaPer87/master

fix: Encode body and update resp.body