Fixed lp:1308146 -  charm config options with $ and . in the names now work

Since local charms can be uploaded via the API server, this issue was
introduced: charms with config options having "$" and/or "." in their
names caused notOkForStorage error from mongodb when trying to save
the charm config into the charms collection. See http://pad.lv/1308146.

Service settings were already treated properly (escaping $ and . on the
way into mongo and unescaping on the way out), so the fix uses the same
approach.

Tested live with a local environment and added a unit test for it.