bug fix; tests added