Refactoring of avatar saving and resizing. Tests passes.