Refactor tests slightly, fix some warnings