Make sure that initial state gets reset if anything goes wrong in ``rc_context`` [backport to 1.4.x]

Fixed a bug that caused rc parameters to not be reset to initial state if an exception happened while setting new rc parameters inside rc_context. This matters because I use ``rc_context`` is a testing suite and one of my tests may *want* ``rc_context`` to fail, but then the rcparams are left in a modified state for future tests. I have included a regression test.

Unfortunately I have to use an ordered dict otherwise the failure is not deterministic (because it depends on the order in which the rcparams are set) so if ordered dict can't import I simply pass the test (I wasn't sure if you make use of the skipping plugin).