Code optimization
Updated tests