format code, fix tests