Bugfixes after functional tests

I fix some bugs after running the last (JUnit) functional tests.