Use JUnit4 expected exceptions instead of manual catch.

Also added a test for doInterval.