Added new tests and fixed errors