\documentclass{scrartcl}

\usepackage{expl3}
\usepackage{tabularx}

\ExplSyntaxOn

\newcounter{testcount}
\setcounter{testcount}{1}

\int_new:N \g_test_int
\int_gset:Nn \g_test_int { 1 }

\cs_new_protected:Nn \test: {
    \int_use:N \g_test_int, ~ \thetestcount

  \int_compare:nTF { \g_test_int = 4 } {
    \int_gset:Nn \g_test_int { 1 }
  } {
    \int_gincr:N \g_test_int
  }

  \int_compare:nTF { \thetestcount = 4 } {
    \setcounter{testcount}{1}
  } {
    \addtocounter{testcount}{1}
  }
}

\let\test=\test:

\cs_new_protected:Nn \reset: {
  \int_gset:Nn \g_test_int { 1 }
  \setcounter{testcount}{1}
}

\let\test=\test:
\let\reset=\reset:

\ExplSyntaxOff

\begin{document}

\reset


\begin{tabularx}{\linewidth}{llll}
    \test & \test &
    \test & \test \cr
    \test & \test
\end{tabularx}

\vspace{1cm}
\reset

\begin{tabular}{llll}
    \test & \test &
    \test & \test \cr
    \test & \test
\end{tabular}

\end{document}
