small fixes & cleaning; added tests