Fixed some new bugs and adapted tests.