Bugfixes to the dirty method and test expansion