Fixes #4670
refactor code
added testRemoveMethodInsensitive
Merge pull request #5567
Merge pull request #5567 in master