Fixes #4670
refactor code
added testRemoveMethodInsensitive