Moved all the tests into functions to clean things up a bit
Tons of improvements to the tests