lib: improve _basename