refactored isEndsWith widget and added test for it