tests: Add pseudorandom number generator

This commit adds custom pseudorandom number generator in bash which can
have a seed set for making repetitive tests. The generator is
thread/process-safe ($RANDOM was failing in functions launched in background)
for making repetitive tests. Tests that are using a random generator were
made repetitive.