Toolcontext process options

improve `ToolContext::process_options`.
This factorizes code and reduces the number of buggy corner-case