external references can now have additional metadata

plus a bit of refactoring and test improvements ...

Working on #45 and #46