added Sandbox.extend unit test and did some refactoring