bugfixes, better tests