Fixed implementation of heap.

Implemented min and max heap using comparator that is selected by
passing constructor arg.
Unit tested.