Separate query from cloud

This will make testing easier
Add test for tag cloud query
Add unit test for tag cloud