Added new tests and fixed issues found while testing