Fix and corresponding test for issue #139
Merge pull request #140 from tjakobsen/fix_for_139

Fix and corresponding test for issue #139