Refactored test code a bit.