Fix mistakes, add some not yet working unittests