Added further tests and fixed some issues