Unit tests reproducting the bug described in #422
Fixes #422