[BUILD] Randomization script refactoring

1) Refactored randomization logic to the top
2) Add logics to support window platforms
Of course, same note about `assert_equal` here and everywhere appropriate... `assert ... == ...` is an antipattern.