Added secure test and other fixes