all_cats sorts by category title.
Added tests for query generating functions.