OOIION-1829 - Adds proper handling for gradient test and mindx sequences

- Updates C code (with better comments too)
- Adds new tests in both python unit tests and C extension tests
- Verifies intended functionality