Refactor test script.
Add further tests.