Refactored to have no global state between tests