GH139: Refactor username validation

Reviewed and approved. Please, merge into master.