fixed a bug in heapsort, added randomized unit tests