more function implementations & unit tests!