Add tests, fix bug