fixed some random number generation stuff and tests