Misc functional and unit test fixes and improvements

Change-Id: I2925f5ab8a56c88c6f328d035097353da89b95f2
Reviewed-on: http://review.couchbase.org/41756
Tested-by: Jeffry Morris <jeffrymorris@gmail.com>
Reviewed-by: Brett Lawson <brett19@gmail.com>