Fixed issue with existing values being overwritten unexpectedly.
Enhanced unit tests.