fix range implementation; add unit tests; add array shuffling