Added support for HTTP headers and json. Also added rudimentary tests.