fix and regression tests for github issue #1258
Merge pull request #1259 from colinsurprenant/issue-1258

fix and regression tests for github issue #1258