add option to return a document fragment

add an option to return a document fragment instead of an array

for the tests, i just copied the current tests and adapted it