Added unit test to bytecodeutils which exposes what I think the bug is