Improve check of topdomain to use

Add more checks and unit tests