Refactor tests into tests package/directory.

Moved the memory testing code to its own module in the tests package. I
started feeling guilty about having test code in the core code. No big
deal now.