fix for bug 997416 return query not list

add test

respond to feedback