use only non-overflowing length in test/random.jl

After rebasing, the changes introduced by commit ea2bd4b9 are
incompatible with tests added in commit 4d1c1382. The problem is that
now any array-like r can be passed to rand (not only ranges), and for
a random element to be picked out of r, a random integer in the range
1:length(r) is generated, and hence `length(r)` has to be a valid
integer (e.g. length(typemin(Int):typemax(Int)) yields OverflowError()).
RandIntGen: improve error message

This is @ivarne suggestion (cf.
https://github.com/JuliaLang/julia/pull/8309#discussion_r18149653):
move invariant checking in inner constructor, and emit a clearer error
message when this fail.