Tests and fix for #94

Starting branch to fix #94. I have a failing test to start with.