A congruence test for subgroups of $SL_2(Z)$