Add more typescript tests and bug fix