fix cap metatable, tests