Make tests

Add more tests. Most are broken due to #782 . This will help dev to figure out how to fix those issues.

also most of the testing bugs are code quality issues having to do with variables implicitly being made global due to lack of declaration of var (and, lets be real, javascripts terrible semantics), which led to the two sides overwriting each other