Completely refactored parsing algorithm.
Added header name trimming and validating.
Added tests for header name parsing.