wrote test for actAsUser and fixed bugs along the way.