Refactored test utilities

Centralized test utilities in a module which contains the utilities for testing with the Core API. Removed most duplicate code from these utility classes.