provide support to export entities with all its references
improve the exception in case there is a bad exception
fixed some minor points and added basic test coverage
fix test failures