bugfix and a load of code cleanups

fixed the http/ClientStream headers funtion, and added a testcase for it
also did a lot of code style cleaning