Just like personalizations, the AB tests are stored on the rendering fields. If you are able to see the AB test on the Experience editor so it means that the test has been set.
Now where does Sitecore store the tests items it associate with my page?
On the Marketing Control Panel /Test Lab bucket. If you open the content editor and search for the existing tests you should be able to see the results there.
Here is a test I have configured on my build associated with my home page:
Looking at your code above I can say you are on the right track but your problem most likely is that the test is configured on the final layout as opposed to the shared layout.
Here is the code slightly changed(look at in this case I'm reading the final layout as opposed to the shared):
Sitecore.Data.Fields.LayoutField layoutField = RenderingContext.Current.PageContext.Item.Fields["__final renderings"];
var renderings= layoutField.GetReferences(Sitecore.Context.Device).FirstOrDefault();
if (renderings != null)
var testID = renderings.Settings.MultiVariateTest;
With this code you should be able to see the ID on a string format of the test on the renderings.Settings.MultiVariateTest property.
Note that the Guid I'm getting on the MultiVariateTest property is matching to the guid from the item the Marketing Control Panel(first screenshot).
Hope this helps.