fix tests; avoid reinterpret_cast; bug in counts