Heap task

Fixed heap, added tests.