tests added, bugs fixed