Fixed tests and fixed some errors