refactor popover test code