Refactoring and Testing the index.php