Log instruction refactoring and tests