Merge pull request #151 from markusjohnsson/Issue150

Fixes issue #150
Add a simple fix for the regression introduced by markus's fix for issue #150. Not sure this is right.
Fix regression introduced with fix of issue #150.

Added test for the specific bug.