encode: fix `escape`, expose it
test: added basic tests for `escape`