shuffle and random_shuffle, tests, bug fixes and clean-up