fixes issue #87

This pr fixes issue #87 and provides a tests for regression checking.