diff --git a/acceptance/openstack/compute/tools_test.go b/acceptance/openstack/compute/tools_test.go
index 0469053..5140caf 100644
--- a/acceptance/openstack/compute/tools_test.go
+++ b/acceptance/openstack/compute/tools_test.go
@@ -6,7 +6,7 @@
 	"crypto/rand"
 	"fmt"
 	"github.com/rackspace/gophercloud/openstack/compute/servers"
-	"github.com/rackspace/gophercloud/openstack/identity"
+	identity "github.com/rackspace/gophercloud/openstack/identity/v2"
 	"github.com/rackspace/gophercloud/openstack/utils"
 	"os"
 	"text/tabwriter"
@@ -16,21 +16,21 @@
 var errTimeout = fmt.Errorf("Timeout.")
 
 type testState struct {
-	o             identity.AuthOptions
-	a             identity.AuthResults
-	sc            *identity.ServiceCatalog
-	eps           []identity.Endpoint
-	w             *tabwriter.Writer
-	imageId       string
-	flavorId      string
-	region        string
-	ep            string
-	client        *servers.Client
-	createdServer *servers.Server
-	gottenServer  *servers.Server
-	updatedServer *servers.Server
-	serverName    string
-	alternateName string
+	o              identity.AuthOptions
+	a              identity.AuthResults
+	sc             *identity.ServiceCatalog
+	eps            []identity.Endpoint
+	w              *tabwriter.Writer
+	imageId        string
+	flavorId       string
+	region         string
+	ep             string
+	client         *servers.Client
+	createdServer  *servers.Server
+	gottenServer   *servers.Server
+	updatedServer  *servers.Server
+	serverName     string
+	alternateName  string
 	flavorIdResize string
 }
 
@@ -240,48 +240,48 @@
 }
 
 func MakeNewPassword(oldPass string) string {
-	fmt.Println("Current password: "+oldPass)
+	fmt.Println("Current password: " + oldPass)
 	randomPassword := RandomString("", 16)
 	for randomPassword == oldPass {
 		randomPassword = RandomString("", 16)
 	}
-	fmt.Println("    New password: "+randomPassword)
+	fmt.Println("    New password: " + randomPassword)
 	return randomPassword
 }
 
 func ChangeAdminPassword(ts *testState) error {
 	randomPassword := MakeNewPassword(ts.createdServer.AdminPass)
-	
+
 	err := servers.ChangeAdminPassword(ts.client, ts.createdServer.Id, randomPassword)
 	if err != nil {
 		return err
 	}
-	
+
 	err = WaitForStatus(ts, "PASSWORD")
 	if err != nil {
 		return err
 	}
-	
+
 	return WaitForStatus(ts, "ACTIVE")
 }
 
 func RebootServer(ts *testState) error {
-	fmt.Println("Attempting reboot of server "+ts.createdServer.Id)
+	fmt.Println("Attempting reboot of server " + ts.createdServer.Id)
 	err := servers.Reboot(ts.client, ts.createdServer.Id, servers.OSReboot)
 	if err != nil {
 		return err
 	}
-	
+
 	err = WaitForStatus(ts, "REBOOT")
 	if err != nil {
 		return err
 	}
-	
+
 	return WaitForStatus(ts, "ACTIVE")
 }
 
 func RebuildServer(ts *testState) error {
-	fmt.Println("Attempting to rebuild server "+ts.createdServer.Id)
+	fmt.Println("Attempting to rebuild server " + ts.createdServer.Id)
 
 	newPassword := MakeNewPassword(ts.createdServer.AdminPass)
 	newName := RandomString("ACPTTEST", 16)
@@ -289,7 +289,7 @@
 	if err != nil {
 		return err
 	}
-	
+
 	s, err := servers.GetServer(sr)
 	if err != nil {
 		return err
@@ -302,12 +302,12 @@
 	if err != nil {
 		return err
 	}
-	
+
 	return WaitForStatus(ts, "ACTIVE")
 }
 
 func ResizeServer(ts *testState) error {
-	fmt.Println("Attempting to resize server "+ts.createdServer.Id)
+	fmt.Println("Attempting to resize server " + ts.createdServer.Id)
 
 	err := servers.Resize(ts.client, ts.createdServer.Id, ts.flavorIdResize)
 	if err != nil {
@@ -323,19 +323,19 @@
 }
 
 func ConfirmResize(ts *testState) error {
-	fmt.Println("Attempting to confirm resize for server "+ts.createdServer.Id)
-	
+	fmt.Println("Attempting to confirm resize for server " + ts.createdServer.Id)
+
 	err := servers.ConfirmResize(ts.client, ts.createdServer.Id)
 	if err != nil {
 		return err
 	}
-	
+
 	return WaitForStatus(ts, "ACTIVE")
 }
 
 func RevertResize(ts *testState) error {
-	fmt.Println("Attempting to revert resize for server "+ts.createdServer.Id)
-	
+	fmt.Println("Attempting to revert resize for server " + ts.createdServer.Id)
+
 	err := servers.RevertResize(ts.client, ts.createdServer.Id)
 	if err != nil {
 		return err
diff --git a/acceptance/openstack/identity_test.go b/acceptance/openstack/identity_test.go
index 02f86ad..f9c26ae 100644
--- a/acceptance/openstack/identity_test.go
+++ b/acceptance/openstack/identity_test.go
@@ -4,7 +4,7 @@
 
 import (
 	"fmt"
-	"github.com/rackspace/gophercloud/openstack/identity"
+	identity "github.com/rackspace/gophercloud/openstack/identity/v2"
 	"github.com/rackspace/gophercloud/openstack/utils"
 	"os"
 	"testing"
diff --git a/acceptance/openstack/storage_test.go b/acceptance/openstack/storage_test.go
index 9792335..5c835cf 100644
--- a/acceptance/openstack/storage_test.go
+++ b/acceptance/openstack/storage_test.go
@@ -4,94 +4,103 @@
 
 import (
 	"bytes"
+	"github.com/rackspace/gophercloud/acceptance/tools"
+	identity "github.com/rackspace/gophercloud/openstack/identity/v2"
 	storage "github.com/rackspace/gophercloud/openstack/storage/v1"
 	"github.com/rackspace/gophercloud/openstack/storage/v1/accounts"
 	"github.com/rackspace/gophercloud/openstack/storage/v1/containers"
 	"github.com/rackspace/gophercloud/openstack/storage/v1/objects"
-	"os"
+	"github.com/rackspace/gophercloud/openstack/utils"
 	"strings"
 	"testing"
-	"github.com/rackspace/gophercloud/acceptance/tools"
 )
 
-var objectStorage = "object-store"
 var metadata = map[string]string{"gopher": "cloud"}
 var numContainers = 2
 var numObjects = 2
 
+func newClient() (*storage.Client, error) {
+	ao, err := utils.AuthOptions()
+	if err != nil {
+		return nil, err
+	}
+
+	client, err := ao.NewClient(identity.ClientOpts{
+		Type: "object-store",
+	})
+	if err != nil {
+		return nil, err
+	}
+
+	return storage.NewClient(client.Endpoint, client.Authority, client.Options), nil
+}
+
 func TestAccount(t *testing.T) {
-	ts, err := tools.SetupForList(objectStorage)
+	client, err := newClient()
 	if err != nil {
 		t.Error(err)
 		return
 	}
 
-	region := os.Getenv("OS_REGION_NAME")
-	for _, ep := range ts.EPs {
-		if (region != "") && (region != ep.Region) {
-			continue
+	err = accounts.Update(client, accounts.UpdateOpts{
+		Metadata: metadata,
+	})
+	if err != nil {
+		t.Error(err)
+		return
+	}
+	defer func() {
+		tempMap := make(map[string]string)
+		for k := range metadata {
+			tempMap[k] = ""
 		}
-
-		client := storage.NewClient(ep.PublicURL, ts.A, ts.O)
-
-		err := accounts.Update(client, accounts.UpdateOpts{
-			Metadata: metadata,
+		err = accounts.Update(client, accounts.UpdateOpts{
+			Metadata: tempMap,
 		})
 		if err != nil {
 			t.Error(err)
 			return
 		}
-		defer func() {
-			tempMap := make(map[string]string)
-			for k := range metadata {
-				tempMap[k] = ""
-			}
-			err = accounts.Update(client, accounts.UpdateOpts{
-				Metadata: tempMap,
-			})
-			if err != nil {
-				t.Error(err)
-				return
-			}
-		}()
+	}()
 
-		gr, err := accounts.Get(client, accounts.GetOpts{})
-		if err != nil {
-			t.Error(err)
+	gr, err := accounts.Get(client, accounts.GetOpts{})
+	if err != nil {
+		t.Error(err)
+		return
+	}
+	am := accounts.ExtractMetadata(gr)
+	for k := range metadata {
+		if am[k] != metadata[strings.Title(k)] {
+			t.Errorf("Expected custom metadata with key: %s", k)
 			return
 		}
-		am := accounts.ExtractMetadata(gr)
-		for k := range metadata {
-			if am[k] != metadata[strings.Title(k)] {
-				t.Errorf("Expected custom metadata with key: %s", k)
-				return
-			}
-		}
 	}
 }
 
 func TestContainers(t *testing.T) {
-	ts, err := tools.SetupForList(objectStorage)
+	client, err := newClient()
 	if err != nil {
 		t.Error(err)
 		return
 	}
 
-	region := os.Getenv("OS_REGION_NAME")
-	for _, ep := range ts.EPs {
-		if (region != "") && (region != ep.Region) {
-			continue
+	cNames := make([]string, numContainers)
+	for i := 0; i < numContainers; i++ {
+		cNames[i] = tools.RandomString("test-container-", 8)
+	}
+
+	for i := 0; i < len(cNames); i++ {
+		_, err := containers.Create(client, containers.CreateOpts{
+			Name: cNames[i],
+		})
+		if err != nil {
+			t.Error(err)
+			return
 		}
-
-		client := storage.NewClient(ep.PublicURL, ts.A, ts.O)
-
-		cNames := make([]string, numContainers)
-		for i := 0; i < numContainers; i++ {
-			cNames[i] = tools.RandomString("test-container-", 8)
-		}
-
+	}
+	defer func() {
 		for i := 0; i < len(cNames); i++ {
-			_, err := containers.Create(client, containers.CreateOpts{
+			err = containers.Delete(client, containers.DeleteOpts{
 				Name: cNames[i],
 			})
 			if err != nil {
@@ -99,264 +108,243 @@
 				return
 			}
 		}
-		defer func() {
-			for i := 0; i < len(cNames); i++ {
-				err = containers.Delete(client, containers.DeleteOpts{
-					Name: cNames[i],
-				})
-				if err != nil {
-					t.Error(err)
-					return
-				}
-			}
-		}()
+	}()
 
-		lr, err := containers.List(client, containers.ListOpts{
-			Full: false,
-		})
-		if err != nil {
-			t.Error(err)
-			return
-		}
-		cns, err := containers.ExtractNames(lr)
-		if err != nil {
-			t.Error(err)
-			return
-		}
-		if len(cns) != len(cNames) {
-			t.Errorf("Expected %d names and got %d", len(cNames), len(cns))
-			return
-		}
+	lr, err := containers.List(client, containers.ListOpts{
+		Full: false,
+	})
+	if err != nil {
+		t.Error(err)
+		return
+	}
+	cns, err := containers.ExtractNames(lr)
+	if err != nil {
+		t.Error(err)
+		return
+	}
+	if len(cns) != len(cNames) {
+		t.Errorf("Expected %d names and got %d", len(cNames), len(cns))
+		return
+	}
 
-		lr, err = containers.List(client, containers.ListOpts{
-			Full: true,
-		})
-		if err != nil {
-			t.Error(err)
-			return
-		}
-		cis, err := containers.ExtractInfo(lr)
-		if err != nil {
-			t.Error(err)
-			return
-		}
-		if len(cis) != len(cNames) {
-			t.Errorf("Expected %d containers and got %d", len(cNames), len(cis))
-			return
-		}
+	lr, err = containers.List(client, containers.ListOpts{
+		Full: true,
+	})
+	if err != nil {
+		t.Error(err)
+		return
+	}
+	cis, err := containers.ExtractInfo(lr)
+	if err != nil {
+		t.Error(err)
+		return
+	}
+	if len(cis) != len(cNames) {
+		t.Errorf("Expected %d containers and got %d", len(cNames), len(cis))
+		return
+	}
 
+	err = containers.Update(client, containers.UpdateOpts{
+		Name:     cNames[0],
+		Metadata: metadata,
+	})
+	if err != nil {
+		t.Error(err)
+		return
+	}
+	defer func() {
+		tempMap := make(map[string]string)
+		for k := range metadata {
+			tempMap[k] = ""
+		}
 		err = containers.Update(client, containers.UpdateOpts{
 			Name:     cNames[0],
-			Metadata: metadata,
+			Metadata: tempMap,
 		})
 		if err != nil {
 			t.Error(err)
 			return
 		}
-		defer func() {
-			tempMap := make(map[string]string)
-			for k := range metadata {
-				tempMap[k] = ""
-			}
-			err = containers.Update(client, containers.UpdateOpts{
-				Name:     cNames[0],
-				Metadata: tempMap,
-			})
-			if err != nil {
-				t.Error(err)
-				return
-			}
-		}()
+	}()
 
-		gr, err := containers.Get(client, containers.GetOpts{})
-		if err != nil {
-			t.Error(err)
+	gr, err := containers.Get(client, containers.GetOpts{})
+	if err != nil {
+		t.Error(err)
+		return
+	}
+	cm := containers.ExtractMetadata(gr)
+	for k := range metadata {
+		if cm[k] != metadata[strings.Title(k)] {
+			t.Errorf("Expected custom metadata with key: %s", k)
 			return
 		}
-		cm := containers.ExtractMetadata(gr)
-		for k := range metadata {
-			if cm[k] != metadata[strings.Title(k)] {
-				t.Errorf("Expected custom metadata with key: %s", k)
-				return
-			}
-		}
 	}
 }
 
 func TestObjects(t *testing.T) {
-	ts, err := tools.SetupForList(objectStorage)
+	client, err := newClient()
 	if err != nil {
 		t.Error(err)
 		return
 	}
 
-	region := os.Getenv("OS_REGION_NAME")
+	oNames := make([]string, numObjects)
+	for i := 0; i < len(oNames); i++ {
+		oNames[i] = tools.RandomString("test-object-", 8)
+	}
 
-	for _, ep := range ts.EPs {
-		if (region != "") && (region != ep.Region) {
-			continue
-		}
-
-		client := storage.NewClient(ep.PublicURL, ts.A, ts.O)
-
-		oNames := make([]string, numObjects)
-		for i := 0; i < len(oNames); i++ {
-			oNames[i] = tools.RandomString("test-object-", 8)
-		}
-
-		cName := tools.RandomString("test-container-", 8)
-		_, err := containers.Create(client, containers.CreateOpts{
+	cName := tools.RandomString("test-container-", 8)
+	_, err = containers.Create(client, containers.CreateOpts{
+		Name: cName,
+	})
+	if err != nil {
+		t.Error(err)
+		return
+	}
+	defer func() {
+		err = containers.Delete(client, containers.DeleteOpts{
 			Name: cName,
 		})
 		if err != nil {
 			t.Error(err)
 			return
 		}
-		defer func() {
-			err = containers.Delete(client, containers.DeleteOpts{
-				Name: cName,
-			})
-			if err != nil {
-				t.Error(err)
-				return
-			}
-		}()
+	}()
 
-		oContents := make([]*bytes.Buffer, numObjects)
+	oContents := make([]*bytes.Buffer, numObjects)
+	for i := 0; i < numObjects; i++ {
+		oContents[i] = bytes.NewBuffer([]byte(tools.RandomString("", 10)))
+		err = objects.Create(client, objects.CreateOpts{
+			Container: cName,
+			Name:      oNames[i],
+			Content:   oContents[i],
+		})
+		if err != nil {
+			t.Error(err)
+			return
+		}
+	}
+	defer func() {
 		for i := 0; i < numObjects; i++ {
-			oContents[i] = bytes.NewBuffer([]byte(tools.RandomString("", 10)))
-			err = objects.Create(client, objects.CreateOpts{
+			err = objects.Delete(client, objects.DeleteOpts{
 				Container: cName,
 				Name:      oNames[i],
-				Content:   oContents[i],
 			})
-			if err != nil {
-				t.Error(err)
-				return
-			}
 		}
-		defer func() {
-			for i := 0; i < numObjects; i++ {
-				err = objects.Delete(client, objects.DeleteOpts{
-					Container: cName,
-					Name:      oNames[i],
-				})
-			}
-		}()
+	}()
 
-		lr, err := objects.List(client, objects.ListOpts{
-			Full:      false,
-			Container: cName,
-		})
-		if err != nil {
-			t.Error(err)
-			return
-		}
-		ons, err := objects.ExtractNames(lr)
-		if err != nil {
-			t.Error(err)
-			return
-		}
-		if len(ons) != len(oNames) {
-			t.Errorf("Expected %d names and got %d", len(oNames), len(ons))
-			return
-		}
+	lr, err := objects.List(client, objects.ListOpts{
+		Full:      false,
+		Container: cName,
+	})
+	if err != nil {
+		t.Error(err)
+		return
+	}
+	ons, err := objects.ExtractNames(lr)
+	if err != nil {
+		t.Error(err)
+		return
+	}
+	if len(ons) != len(oNames) {
+		t.Errorf("Expected %d names and got %d", len(oNames), len(ons))
+		return
+	}
 
-		lr, err = objects.List(client, objects.ListOpts{
-			Full:      true,
-			Container: cName,
-		})
-		if err != nil {
-			t.Error(err)
-			return
-		}
-		ois, err := objects.ExtractInfo(lr)
-		if err != nil {
-			t.Error(err)
-			return
-		}
-		if len(ois) != len(oNames) {
-			t.Errorf("Expected %d containers and got %d", len(oNames), len(ois))
-			return
-		}
+	lr, err = objects.List(client, objects.ListOpts{
+		Full:      true,
+		Container: cName,
+	})
+	if err != nil {
+		t.Error(err)
+		return
+	}
+	ois, err := objects.ExtractInfo(lr)
+	if err != nil {
+		t.Error(err)
+		return
+	}
+	if len(ois) != len(oNames) {
+		t.Errorf("Expected %d containers and got %d", len(oNames), len(ois))
+		return
+	}
 
-		err = objects.Copy(client, objects.CopyOpts{
-			Container:    cName,
-			Name:         oNames[0],
-			NewContainer: cName,
-			NewName:      oNames[1],
-		})
-		if err != nil {
-			t.Error(err)
-			return
-		}
+	err = objects.Copy(client, objects.CopyOpts{
+		Container:    cName,
+		Name:         oNames[0],
+		NewContainer: cName,
+		NewName:      oNames[1],
+	})
+	if err != nil {
+		t.Error(err)
+		return
+	}
 
-		dr, err := objects.Download(client, objects.DownloadOpts{
-			Container: cName,
-			Name:      oNames[1],
-		})
-		if err != nil {
-			t.Error(err)
-			return
-		}
-		o2Content, err := objects.ExtractContent(dr)
-		if err != nil {
-			t.Error(err)
-		}
-		dr, err = objects.Download(client, objects.DownloadOpts{
-			Container: cName,
-			Name:      oNames[0],
-		})
-		if err != nil {
-			t.Error(err)
-			return
-		}
-		o1Content, err := objects.ExtractContent(dr)
-		if err != nil {
-			t.Error(err)
-			return
-		}
-		if string(o2Content) != string(o1Content) {
-			t.Errorf("Copy failed. Expected\n%s\nand got\n%s", string(o1Content), string(o2Content))
-			return
-		}
+	dr, err := objects.Download(client, objects.DownloadOpts{
+		Container: cName,
+		Name:      oNames[1],
+	})
+	if err != nil {
+		t.Error(err)
+		return
+	}
+	o2Content, err := objects.ExtractContent(dr)
+	if err != nil {
+		t.Error(err)
+	}
+	dr, err = objects.Download(client, objects.DownloadOpts{
+		Container: cName,
+		Name:      oNames[0],
+	})
+	if err != nil {
+		t.Error(err)
+		return
+	}
+	o1Content, err := objects.ExtractContent(dr)
+	if err != nil {
+		t.Error(err)
+		return
+	}
+	if string(o2Content) != string(o1Content) {
+		t.Errorf("Copy failed. Expected\n%s\nand got\n%s", string(o1Content), string(o2Content))
+		return
+	}
 
+	err = objects.Update(client, objects.UpdateOpts{
+		Container: cName,
+		Name:      oNames[0],
+		Metadata:  metadata,
+	})
+	if err != nil {
+		t.Error(err)
+		return
+	}
+	defer func() {
+		tempMap := make(map[string]string)
+		for k := range metadata {
+			tempMap[k] = ""
+		}
 		err = objects.Update(client, objects.UpdateOpts{
 			Container: cName,
 			Name:      oNames[0],
-			Metadata:  metadata,
+			Metadata:  tempMap,
 		})
 		if err != nil {
 			t.Error(err)
 			return
 		}
-		defer func() {
-			tempMap := make(map[string]string)
-			for k := range metadata {
-				tempMap[k] = ""
-			}
-			err = objects.Update(client, objects.UpdateOpts{
-				Container: cName,
-				Name:      oNames[0],
-				Metadata:  tempMap,
-			})
-			if err != nil {
-				t.Error(err)
-				return
-			}
-		}()
+	}()
 
-		gr, err := objects.Get(client, objects.GetOpts{})
-		if err != nil {
-			t.Error(err)
+	gr, err := objects.Get(client, objects.GetOpts{})
+	if err != nil {
+		t.Error(err)
+		return
+	}
+	om := objects.ExtractMetadata(gr)
+	for k := range metadata {
+		if om[k] != metadata[strings.Title(k)] {
+			t.Errorf("Expected custom metadata with key: %s", k)
 			return
 		}
-		om := objects.ExtractMetadata(gr)
-		for k := range metadata {
-			if om[k] != metadata[strings.Title(k)] {
-				t.Errorf("Expected custom metadata with key: %s", k)
-				return
-			}
-		}
 	}
 }
