PHP tests added, functions restructurized