Refactored common test code, added failing test ready for API code.