Refactoring of update method and added update test