Cleaned up unit tests and abstracted them a bit