Move StaginAPI into a module. Fix tests.