some tests added, some bugs fixed