I try to remove message from inbox folder and all alright, but when i switched to All Mail folder the removing does not work. expunge() method returns (\'
With Gmail advanced IMAP controls you can set what happens to messages when you delete them over IMAP.
Just enable "Advanced IMAP Controls" in Gmail Labs. The settings page will look like this:

Then when you mark a message as deleted and expunge as per this answer it will be moved to the bin, permanently deleted, or archived to "All Mail" depending on what setting you selected.