Fix prepared dispose after connection close

NpgsqlCommand now listens to its connection's open/close events.
On close, sets its prepare status to NotPrepared, avoiding the
DEALLOCATE on Dispose().

A bit of additional cleanup around command/connection relations,
but further work is needed for cases where the same command gets
transferred across connections.

Fixes #393
Relates to #299

(cherry picked from commit 5329b664c4eb57808d5a5529363632c5f2d885e2)

Conflicts:
	Npgsql/NpgsqlCommand.cs
	tests/CommandTests.cs