Adds a fix and a unit test for the bug 697