tests added and bugs fixed