Switch remove unsafePerformIO from test sources

Remove the use of unsafePerformIO/IORef "globals" for testing data
sources in favour of the new per-source state.