fix bad interaction of null with value classes

db.entity and db.entid both return null if given a lookup ref that does not resolve.

Constructing the Entity value class from the return value of a method that can return null causes problems. And also, null.asInstanceOf[Long] == 0. This fix tests for nulls and throws exceptions.

To be able to test for lookup ref resolution without needing to trap exceptions, helper methods are added to the lookup ref class that return Option.
Merge pull request #106 from pellucidanalytics/fix/nulls

fix bad interaction of null with value classes