Fixed some concurrency issues with testing

Fixing the concurrency issues in test has exposed the bad way in which
how datasources are handled.