(get_configuration_state, restore_configuration_state): New functions.

(selftest): Save and restore configuration test around the test.
Notably, this will normally deactivate loopback mode again.