Re-organized header parser for re-entrant calling

Also enables testing individual sections of parseHeader(),
which is nice.