Bugfixes and test updates