Add tests for #287
Patch for issue #287 (thanks to @eltjpm)