Fix checks for keys to generate cn

I guess that the second `if' was incorrect, because it didn't check
`fname' availability, it just used it. Now, if `fname' is available,
it's used and `sname' is added when available.