adding more tests and bug fixes due to finds in testing code

Signed-off-by: Andrew Grosner <andrew.grosner@raizlabs.com>
made massive changes to foreign keys, with respect to tests failing. for some reason the foreign key test still fails.