Add some tests and fix js