Added a test() method and refactored.