Support compact key domain storage

- Make key domain tests dynamic, test outside range of ints
- Abstract storage of key domains
- Use int[] to store key domains if the values are small enough