Fixed header and output hooking procedure
Fixed a test case.

Not really related, but can't be bothered to put it in a separate PR.
Merged pull request #74