Refactored and tweaked tests