Improved error handling and one fix in order to detect #1103 issues

Take a look at this, @Kartones . This is mostly error handling improvements, including some deleted error shallowing that might be responsible of not detecting what's happening under the hood. On one hand more errors will be shown, but on the other mail won't send a not working, success link, and we should be able to see better logs.
No it isn't. I extracted some code between add_processed_column and remove_processed_column to process_batched_query method in order to improve error handling. Some variables had to be moved outside containing block in order to be available after its execution.