bugfixes to make tests pass