Add common "edit" function and refactor code

Increase the amount of shared code. Not sure if the functions belong in
MassMessageListContentHandler, though. Also fix issue where imported
targets may not be sorted when creating a new spamlist.

Change-Id: Ic52cf52aa32f778f75567ae1ffa52e721c6718f9