Fix for PR #102

This is replacement PR for #102 that includes passing tests.