Refactoring shuffle and improve tests