split-up the update script and add unit tests for it