Added minmax function.
Tests ok