modified gravatar function
added tests and cleaned code