Fixed problem of multiple IDs sent to output.

Added test so that ids will only be processed from document-meta, or
source-meta with no following-sibling document-meta