[tests] moved some shared logic to the helper