Issue #1327 regression test and fix

Hi Travis, I came up with a regression test and a fix, please merge or cherry-pick.

may want to `throw null` somewhere to test an edge case?

see also 8de3bc8c4d40b0fa870c9042b61cd78ee9f1db7a