Refactored and made tests for morris_optimal