Improve integrity checks when setting boundary conditions

We were previously not checking whether a DirichletBC is applied to a
Function on the same FunctionSpace. Check for that and also make sure
that setting a DirichletBC after construction is properly converted.