Add tests and improve npm dependency handling