added some new tests and minimized queries
reduces queries for publish
Merge pull request #2850 from digi604/fix-2802

Fix 2802 (reduces publish queries)