Fixes to allow tests to run on mysql 5.5 without triggering metadata locks. Also a revamp of the to_dict function, to handle cases where columns have been aliased.