Fixes #113.

Fixed bug in issue #113 and added unit test accordingly.