Cleaned up for my own use
Get tests to pass