Refactor test for opaque keys