fix tests and bug