In addition to the pure collision detection I'd also check, whether the centers of the squares move towards each other or not and only revert their velocity in the first case. For me to provide an example you'd have to provide information about your implementation of the Square
class.
Edit: Essentially the logic would look something like this:
if (collision detected) {
if ( (square2.posx-square1.posx)* (square2.vx-square1.vx) < 0) {
// EDIT: exchange velocities of square1 and square2 in x direction
}
if ( (square2.posy-square1.posy)* (square2.vy-square1.vy) < 0) {
// EDIT: exchange velocities of square1 and square2 in y direction
}
}
This is of course far from a realistic collision simulation, but if you just want to see whether your collision detection works correctly it should suffice. Btw. I'm assuming, that the rectangle edges are all oriented along the x and y axis.