Heap implementation and tests.