Add tests and use defn in main