Fixed failing tests and removed debug code