MDL-45594 core_message: altered queries to order by timecreated, rather than id.
MDL-45594 core_message: added unit tests