If we have n numbers u[0], u[1], ..., u[n], the serial correlation C is
      n(u[0]*u[1]+u[1]*u[2]+ ... +u[n-1]*u[0])-(u[0]+u[1]+ ... +u[n-1])^2
C=   --------------------------------------------------------------------------------
    n(u[0]*u[0]+u[1]*u[1]+ .. +u[n-1]*u[n-1])-(u[0]+u[1]+ .. +u[n-1])^2

A good value of C will be between u_n - 2*s_n and u_n + 2*s_n where
u_n = -1/(n-1)
s_n = n^2/((n-1)^2*(n-2))

and C should be between these limits about 95% of time.
In this testing, we assume that u_n - 4*s_n to have p-value of 0 and u_n + 4*s_n to have p-value 1.0 and then evaluate C. We calculate 10,000 C and apply KStest on the 10,000 these values to get the final p-value. The test is failed if the value less than 0.001 or larger than 0.999.