fix a bug with the dashboard redirect, add some tests and tidy up a few things