Add tests. Fix bugs found by tests.

Add tests for skip() and substitute().
Add logOnException().