reworked lib & tests