Support custom random number generator in random() and shuffle()

I added support for specifying a custom random generator function to random() and shuffle(). This is useful if you want to make functions that use these functions testable (by passing in a stable/predictable generator), if you want to have predictable results, ...