Fix bug in test_query_math