Test cases not working even after output is right