unit tests from Andrew Anderson and Pratik Patel