Add a bunch of docs and tests.

Add a bunch of docs and tests.