test fix
some refactoring and tidying of avatar helper