fix predict function, add a few tests