Fixing issues with tests...

... and making behaviour switching more robust.