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