fix tests and code issues