refactoring/unit testing of appointmentviewer.core