Add unit tests for topology sorting