more unit tests + technical debt

This was a major cleanup that addressed all comments from Lucas w.r.t. [1], and more.

[1] https://github.com/uproxy/libfte/pull/1