Cleaned up imap undo code a bit in preparation for fixing undo after expunge, bug 323875

Fixed adding of new headers to open cross-folder threaded saved searches, bug 505321, added a test for that to test_nsMsgDBView.js, and fixed the error detection functions in that file so that they detect errors.

Started work on auto sync disk usage constraints bug 482476 – wrote patch to enable marking of msg headers as pending removal so that offline store compaction will reclaim space, pending review.