[BUILD] Randomization script refactoring

1) Refactored randomization logic to the top
2) Add logics to support window platforms
This should be [`assert_kind_of`](http://ruby-doc.org/stdlib-1.8.6/libdoc/test/unit/rdoc/Test/Unit/Assertions.html#method-i-assert_kind_of).