Added test script.
Bug fixes from testing.