[server][testItemGroup] Extract commonly used lines as a function.