[composer] Clean up code, move some methods to QgsComposerUtils, const correctness, tests, doc improvements