Some more unit tests, small fixes