Toolcontext process options

improve `ToolContext::process_options`.
This factorizes code and reduces the number of buggy corner-case

The second PR of the #353 series