basic linting pass (lots of nonsense with variable scope that isn't worth fixing right now)
forgot to merge the test cases correctly