Fixed tests and removed old code