Fix bugs which test code found.