Unittests are really close. Few minor bugfixes.