Fixed 'next' status from never being removed after multiple transitions.

Messages with next would be marked as processed while still marked as unseen.
This change moves the 'processed' marking to be applied only when transitioning
a messages state from 'unseen' to 'seen'.
Also fixed an issue with test file in regard to the permanent test that was
discovered while writing the test for this issue.