Mostly add more tests
style changes, including using "var" where appropriate
Fix tests