People who are tone deaf do know they are "singing it wrong". But let's assume that since you passed the test that you are NOT in fact tone deaf.
Humans learn to intuitively replicate pitch with their voice just by hearing the pitch. Musicians have to learn how to replicate a given pitch on their instrument. This learning process takes intentional practice and a great deal of time. Eventually a musician begins to develop a memory of what to do to play a given note - much the same way we memorized what to do with our vocal folds and mouth and throat to reproduce a given sound with our voice or by whistling.
But my thoughts are that before you can begin to learn how to translate a melody to your guitar, you would need to be able to translate the melody in your imagination - to a vocal representation. In other words you should be able to sing or hum or whistle the melodies you hear in your head.
If you cannot do this at this time, you might benefit from ear training. I would recommend seeking out the services of a professional teacher to at least evaluate your current abilities and prescribe or recommend a course of instruction or training regimen that will help you get from where you are now - to where you need to be to accomplish your goals.
Here is a link to the Wikipedia article on Ear Training - Wikipedia
While you are working on ear training, you can also start playing scales backwards and forwards on your guitar. Focus primarily on the scales you are most likely to use for your melodies. Practice playing the 7 note diatonic scale through multiple octaves backwards and forwards. Also practice playing pentatonic (5 note scales) to help with recognizing larger intervals.
Playing scales will help you internalize in your brain which fret and string combination corresponds to a given note.
I wish you success as you develop the ability to translate the melodies in your head into something you are able to share with the rest of the world. Good luck!