moved imap_test function to right place