Add support for headers

Add support for passing custom headers to different requests and
also reading response headers.

Also bundle in few bug fixes.
Improve test server code

Just minor improvements for test/example server code.