Rasise the right exception when blocking user creation.

Previously, instead of a useful exception, an UnboundLocalError was
thrown due to the variable being used in constructing the desired
exception not existing. This commit fixes this, and modifies the tests
to check the values from the exceptions.

Change-Id: I653059bc1ccb70340066daf72efc1c1f37d85dd4