Add tests; support streams input and output