Fix Data object support (with test)

This is basically a fork from #119, a merge to latest sources and a test case I just wrote.