Test error message for too few documents
Test error for bad regex
Extract common code