Removed code duplication
Cleaned up some tests