[test][UsersView] Extract generic code as a function