Every time I do a coding test, I always overlook certain optimizations because I'm too stressed to think clearly. After the interview is done, I quickly realize what I did wrong. When this happens, I send a follow-up email where I tell the hiring manager that i made a mistake, and I provide my corrected code or explain what I should have done differently. I've landed two different jobs before by doing this. (One was a live coding test and the other was a take-home test.) So don't be afraid to follow up with corrections, even if the deadline for the take-home test has passed.