polished and tests fixed