check preconditions and unit tests