added test case for update, refactoring