Fix require order. Add tests.