Move tests into a test package

Also fix some minor stylistic issues.