BUG Fix logic in deployer detection

In some cases the DeployerID isn't set properly on the DNDeployment.

Also fixes a minor issue in the unit tests where substituted classes aren't saved properly to the DB.