I was concerned about using this technique in production code but you mentioned that it should be used for test only. If this is for test only then LGTM