Fixed a neverending-loop bug in the header deserialiser, added testcase