Improved relation support

Added basic api tests