tests: Add pseudorandom number generator

This commit changes a random number generator to provided by bash function
$RANDOM. It also provides an ability to change seed in random generator
for making repetitive tests. Tests that use it are also updated.