some modifications and new tests added