Correct header length checking logic. Improve exception message.
Merge pull request #337 from square/jw/logic

Correct header length checking logic. Improve exception message.