various improvements + tests

* ensure linked entities are properly normalized before they enter the store
* add some high level tests
* add testem
* various other improvements and changes