cafd117437
Use t.Setenv in tests, add error return handling, and replace WriteString(fmt.Sprintf(...)) with fmt.Fprintf.