Tests reproducting the bug described in #422
Fixes #422