Yes, this will work fine, as long as we assume that $A$ and $B$ have all their eigenvalues in $GF(p)$ (or, equivalently, strengthen your assumption to say that $A$ and $B$ are diagonalizable over $GF(p)$. Possibly this is already what you intended.) The proof which you cite works over any field; there's no need for it to be algebraically closed.