Throw correct exception.
Add API reference tests.