tests added and appropriate bugs fixed