OptFQDN improvements

 - patch by Vaclav Michalek,
 - with fixes and unittests by Thomson