FIX: issue #839 (Crash: take/part over tail)
Merge pull request #841 from qtxie/issue-839

FIX: issue #839 (Crash: take/part over tail)