Improve imports from lib.helpers

lib.helpers should be less entwined in the codebase and move towards a template helpers role

These patches move some core libs into a new file ckan.common and generally improve imports from lib.helpers
If this is accepted then further clean-ups can be made to the code going forward