Test for attachment data text extraction

Refactor code into attachment data