Unit test and fix for issue #125