Small bugfixes to make tests more stable.