Added tests and tweaked formatting.