Fixes and unit tests for the working directory upgrade step