Fix Pool tests.

At any phase in the test where multiple edges are ready
simultaneously, acquire all edges and sort them into a predictable
order. This allows the test to execute deterministically regardless
of the order of edge allocation.
Merge pull request #568 from riannucci/fix_test

Fix pool tests (and provide utility to fix other similar issues as well)