You're right in that my interpretation was first some what wrong.
Barnes commentary on that verse should clear things up:
"Keep the commandments - That is, do what God has commanded. He in the next verses informs him what he meant by the commandments. Jesus said this, doubtless, to try him, and to convince him that he had by no means kept the commandments, and that in supposing he had he was altogether deceived. The young man thought he had kept them, and was relying on them for salvation. It was of great importance, therefore, to convince him that he was, after all, a sinner. Christ did not mean to say that any man would be saved by the works of the law, for the Bible teaches plainly that such will not be the case, Romans 3:20, Romans 3:28; Romans 4:6; Galatians 2:16; Ephesians 2:9; 2 Timothy 1:9. "