Fix embedded documents on inherited referenced documents

Fixes #872 

/cc @vmattila