Fix doc & add tests for ref returns