Fix unit test. Re-calculate priorities instead of using a priority queue.