do deregister earlier when resources are freed. Extract consistency check method and do proper exception handling which was not 100% appropriate since it was in try block designed for implementation.
deregister order seemed to break test. fix it.