more unit tests plus bug fix.