implementation of random generator and uniformity tests