Fix some tests and examples that sometimes failed

Sometimes random graphs or dict order made these tests/examples fail with nosetests.