Use reversed() to avoid side effect

Also, correct the order of arguments in self.assertEqual().