replace clusters of asserts with single helper routine