Added test for #1011 and #1021