fix for issue #306
Merge pull request #307 from jswhit/master

fix for issue #306 and a new test