Added controller tests for the query analysis controller and changed the code to get most of them to pass. I also did some miscellaneous other things.