Small code cleanup en fixed unittests

Some unittests didn't work any more. 

Also some small code cleanups were done.