Fix failing test and example code

The HeaderTest failed: The headers are stored in a HashMap internally, so the order of the parameters in undefined. This was not considered in the test. This fix sorts the header lines prior to comparison.