Added minmax function.

Fixed test.