fixing #818, respecting #591, adding a test