In your code, test is an Array{VariableRef, 2}. But test[p] just selects one element, not a vector. This isn’t specific to JuMP. See:
julia> x = rand(3, 3)
3×3 Array{Float64,2}:
0.0576085 0.285097 0.125166
0.701127 0.35993 0.462062
0.727124 0.182186 0.378751
julia> x[1]
0.05760854662389847
As @leethargo says, you need a slice: test[p, :] ![]()
p.s. You might want to read Please read: make it easier to help you. It has some advice of formatting the code in questions and making a minimum working example.