If the user specified a target machine, I am not sure we care whether it is "clean" (i.e. not assigned to any units) or not. I'd be inclined to simplify this logic with just `this.db.machines.getById(toMachine)`. My understanding is that juju-core would go ahead and assign the unit to the given machine even if the latter already hosts a unit. So we should do the same.

Another consideration, maybe for a different card/investigation: looking at http://bazaar.launchpad.net/~go-bot/juju-core/trunk/view/head:/juju/deploy.go#L93 it seems that toMachine can be either an existing machine or container (e.g. 3/lxc/2) or a new container on a machine (e.g. lxc:3). Here we handle the former case but not the latter, in which we'd need to parse the machine spec, create a new container in our db and assign the unit to that container. The fakebackend already has the logic to add new machines/containers (see addMachines and _addMachine methods).