Fixed tests and removed unused code