More unittests, small cleanups