Add some tests; minor style changes