fix tests, find bugs