fix for bug 997416 return query not list

add test

respond to feedback
Merge pull request #1954 from dethe/return_query_not_list

fix for bug 997416 return query not list