Fixed #228

And added a test for it.