validateWidgetContext function and test added