Fix Data object support (with test)

This is basically a fork from #119 plus a test case I just wrote.