Add test, style fixes, and other minor error fixes