Fix bug of query and Add test of query
Fix compile-warning