Fixes #443

Also improved related test.