Added more test code and fixed the RNG