Adding tests; fixes ensue.