Cleanup belongs to tests

simplified logic to calculate number of queries by using assert_queries
Merge pull request #11307 from jetthoughts/cleanup_assert_sql

Cleanup belongs to tests