correct getLatestTDoc for polymorphic fmailies (refs #4279)
correct gettdoc functions for polymorphic documents (refs #4279)
add test for gettdoc functions (refs #4279)