Made tests more efficient.
- Moved stuff into helper functions.