Refactor tests

I refactored the tests a bit to remove duplicate stubbing code.