Fix parser advancement in header functions
After parsing a valid header, the current line of the parser should be
the last line of the header. If the header is invalid (the parse
function returns an error), the state of the parser is undefined.
Also add a test since this is easy to mess up.