Backported test case for #1700

(cherry picked from commit aa2ec0f2cc61d74902869b2626a3ba66e5c7010e)