Cleaned up and added return-code tests.