Test code refactored