Tighten type check in domain (closes #15)

This is a port of Sandy's fix for the master branch (#18) for 7.0, replacing #16.