Test code refactoring