Refactor mediacheck and memtest tests.