Fix unit tests.
Variable refactoring and remove the --write-json option.