fix for #240
tests for #240