Restructuring for better testing