No global state for isolated tests and other fixes