Fixed bug in MinMaxIndex and added tests.