Change statement sorting in tests

This modification changes the way statements are sorted in ``assertStatementsEqual()`` before comparison.

In the previous version the order was not clearly defined whenever statements had the same value, which led to failing tests due to different sorting.

This change adds some additional (secondary) sorting criteria to avoid these cases.