Modified the update.py module and added a unit-test for it

* Some comment re-factor.
* Unnecessary swapping of the dicts removed.
* unconditional dict swap at the end removed.
* 2 unit-tests added to be sure it works.