Reworked some of the testing stuff to not use globals.