Added test and fix for #652