Fix #766.
Merge pull request #778 from jails/dev/grid-fs

Tests for #766.