Refactor tests for opaque keys