```ts
import { strict as assert } from 'assert';

const MODULUS = 1000000007;

/** The nth Fibonacci number, modulo 1000000007. */
export function fibMod(n: number): number {
  if (typeof n !== 'number' || !Number.isInteger(n) || n < 0) {
    throw new Error('Input must be a non-negative integer.');
  }

  let a = 0, b = 1;
  for (let i = 2; i <= n; i++) {
    const next = (a + b) % MODULUS;
    a = b;
    b = next;
  }
  return b;
}

// Test cases
try {
  assert.equal(fibMod(0), 0);
  assert.equal(fibMod(1), 1);
  assert.equal(fibMod(2), 1);
  assert.equal(fibMod(3), 2);
  assert.equal(fibMod(4), 3);
  assert.equal(fibMod(5), 5);
  assert.equal(fibMod(6), 8);
  assert.equal(fibMod(7), 13);
  assert.equal(fibMod(200000), 422400);
  console.log('All test cases passed!');
} catch (error) {
  console.error('Error in test cases:', error);
}
```