fix situation leading to infinite derivative, add test case
Merge pull request #116.