Tiny code refactoring and update test code