Fix some variable bugs and start more tests