Media playback is unsupported on your device Media caption Tunisian police raid suspected terrorist hideout

Tour operator Thomas Cook is taking British tourists back to Tunisia this week for the first time since an ISIS gunman massacred 38 people - 30 of them British - on a beach in Sousse in 2015.

Until last summer, the Foreign Office advised against travel there due to the high risk of terrorism.

So what has changed and is it safe for western tourists to go back?

On a beach of pristine sand, the sun beats down from a cloudless sky and the turquoise blue of the Mediterranean glitters on the horizon.

But something is missing: tourists.

Admittedly, it's February and therefore low season, but the place is almost completely deserted. Lines of lonely parasols stretch away into the distance and the hotel lobby is empty.

This is Port El Kantaoui near Sousse, where on a hot summer's day in June 2015 a Tunisian jihadist, who had been trained across the border in Libya, strode onto the beach with an assault rifle hidden inside a rolled-up parasol.

He proceeded to calmly shoot dead 38 people, mostly Britons, as they lay on their sunbeds or tried to flee.

Cataclysmic shock

The police were initially nowhere to be seen. Horrified Tunisians shouted at him to stop and bravely formed a human chain across the beach to stop him moving on to the next resort.

The gunman, Seifeddine Rezgui, was eventually cornered in a nearby backstreet and shot dead by police. The bullet holes are still there in the wall today.

Image copyright Frank Gardner Image caption A deserted beach at Sousse, the tourist resort where a jihadist killed 38 people

That Sousse attack came just three months after an earlier one on the Bardo Museum in Tunis that killed 22 people.

For normally peaceful Tunisia, still reeling from the 2011 revolution that deposed long-time dictator Zine El Abidine Ben Ali, this was a cataclysmic shock that shattered its tourist industry.

In 2014, the year before the attacks, says Tunisia's ambassador to London, there were 430,000 visitors from Britain. Last year there were just 28,000.

Image copyright Frank Gardner Image caption Tunisia's hotel industry was badly hit by the terrorist attacks of 2015

This week Thomas Cook, which will be operating fully booked flights from Manchester, Birmingham and Gatwick, says it is expecting only around a quarter of the volume they had in 2014. Tour operator TUI is waiting until May to return.

Yet British officials say Tunisia has made huge progress in counter-terrorism since those attacks.

Quietly, behind the scenes, Britain and other western governments have been helping the Tunisians raise their security standards to the point where JTAC, the UK's Joint Terrorism Analysis Centre, recommended lifting the Foreign Office's travel restrictions.

British aviation security experts have helped carry out a complete overhaul of security at Tunis, Djerba, Monastir and Enfidha airports.

Explosive detection systems have been donated and installed and there is now a best-practice cooperation deal signed between Tunis Carthage airport and Bristol airport.

The Ministry of Defence has undertaken to train up the National Guard in maritime interdiction and port security.

Counter-terrorism detectives from the Metropolitan Police have been working with hotel staff in resort towns to train them in what to look out for in terms of suspicious activity.

Watchful eye

In the grounds of a family-run hotel in Hammamet, owner Mehdi Alani says: "The attacks of 2015 were a wake-up call for Tunisia.

"We never expected anything like this.

"Since then, we have completely upgraded our security procedures.

"Anyone looking to work here has to submit their ID to the Interior Ministry for vetting."

Mr Alani points towards the beach, where heavily-built men in suits pace up and down, keeping a watchful eye.

"We've installed 60 CCTV cameras and we can call up a police response, if need be, from just up the road."

Image copyright Frank Gardner Image caption The UK government wants to help Tunisia expand its tourism industry to take in cultural sites, like these Roman ruins at Oudna

The police response, or lack of it, was one of the most shocking things about the Sousse attacks in 2015.

Since then, the French have been giving firearms training to Tunisia's police, while some officers are now being prosecuted for a dereliction of duty on that day.

Britain's MI6 secret intelligence service has been helping Tunisia to improve its intelligence-gathering capabilities. Yet several problems remain.

Tunisia sits in a dangerous place.

Libya, next door, is still partly in chaos after the collapse of law and order in 2011.

The Manchester bomber, Salman Abedi, trained there and Tunisian officials believe large numbers of their nationals who went to join ISIS are now hiding in remote camps in Libya.

Down at the border crossing point at Ras Ajdir, there is a steady stream of traffic coming across from Libya.

"We only search 10% of the vehicles, based on profiling," says a customs officer, "but we use newly-installed X-ray scanners from America to look inside the vehicles".

Image copyright Frank Gardner Image caption Tunisia's Garde Nationale patrol the border with Libya

America, along with Germany, has also helped Tunisia build a 120km (75 mile) border ditch that stretches along the Libyan frontier down into the Sahara.

There are plans to introduce unmanned drone patrols and other electronic surveillance.

Then there is the economic malaise.

Tunisia may be culturally rich - its fabulous Roman ruins are just waiting to be explored - but it's running out of money.

Image copyright Frank Gardner Image caption UK security experts have helped Tunisia overhaul its security at airports

Tighter border controls with Libya have put a lot of petty smugglers out of business, reportedly driving a small minority to go off and join ISIS.

In provincial towns I saw large numbers of men just sitting around in cafes, jobless and bored.

The widespread resentment of the privileged elite in Tunis that helped trigger the 2011 uprising has not gone away, it's just gone underground.

Efforts to stamp out corruption have not gone far enough, say Tunisians.

Image copyright Frank Gardner Image caption Bookings by British tourists to Tunisia has fallen by 90% since 2014

One of the problems that has had to be addressed at airports is people bribing their way to pass through customs more quickly or even without being searched.

Britain's ambassador to Tunis, Louise de Sousa, said when asked if Tunisia is safe enough now for British tourists to return: "No country can be 100% safe [from terrorism].

"But we are satisfied that Tunisia has made substantial progress and I would encourage Britons to come and visit. This country has so much to offer."