Rewrite mangle_args_for_default_framework + tests

* Rewrite mangle_args_for_default_framework to remove some bugs and be more
  permissive in the way options and content are taken
* Add tests to cover various corner cases of this mangling