[MS,AP]{test after code refactoring} - Tests for offline message sending added + minor refactoring.