Raising a useful error and adding a speccific tests

Fixes #506
The problem is that `m[header]` is None, so it will return None. Note that `m` is already a defaultdict that returns None if the key does not exists, so this call does not help...