Fixed (#841)

This is a fix for #841 and supporting test.
Sure, give me 2 sec :smile: