[BUILD] Randomization script refactoring

1) Refactored randomization logic to the top
2) Add logics to support window platforms
This could be also written as `working_directory = ENV.fetch 'WORKSPACE', (Gem.win_platform? ? Dir.pwd : '/var/tmp')` -- the `ENV.fetch "something", "default"` is a nice pattern.