added tests to ensure entity caching works.
fixed Entity serialization.