Fix code styling issues.

Also add some tests.