Test cases for #784

I can confirm: your change works for me.

I've added test cases issue #784 .