add unit tests, fix collect static bug