Fix for #16

Fix and test for #16, ported from 3.10.x branch