MDL-39572: Fix existing tests and add more to demonstrate issue with sql_order_by_text()