Cleaned up handling of random generators in tests