some fixes + unittest