Fixes #218
Fixes #218 and test for #218