fix issue #40

Added test case and comments.