Actually, it does successfully restore the buffer that was current, as the newly current buffer. Try this:
(switch-to-buffer-other-window "Test buffer."))
(message "current: %S" (current-buffer)))
current-buffer is not related to any particular window. The buffer that is displayed in the (newly) selected window is buffer
Test buffer.. But the current buffer is the original buffer - the one that was saved and restored by
Don't confuse the current buffer with a buffer that is currently displayed. You'll see the same behavior if you use
switch-to-buffer instead of
switch-to-buffer-other-window, in your test function. The buffer that is displayed is
Test buffer.. But the
current-buffer is the saved-and-restored buffer that was originally current.
See the Elisp manual, node Current Buffer.