sort tests are added and selectEntity was out of date.
add some exception classes.