fix for #3198
test for 3198 and update for other tests
Merge pull request #3211 from bilalyasar/issue3198

fixes #3198 + unit test