Added a test, minor refactoring, license headers.