applyed some @fpotter's fu and fixed tests