Fix scoping issues between tests and external use